package com.zj.leetcode.easy;

/**
 * @program: algorithm
 * @description: 657. 机器人能否返回原点
 * @author: Zhang Bo
 * @create: 2022-01-11 16:02
 **/
public class RobotReturnToOrigin {
    public static void main(String[] args) {
//        String s = "UD";
        String s = "LL";
        Solution solution = new RobotReturnToOrigin().new Solution();
        System.out.println(solution.judgeCircle(s));
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public boolean judgeCircle(String moves) {
            int x = 0;
            int y = 0;
            for (int i = 0; i < moves.length(); i++) {
                if (82 == moves.charAt(i)) {
                    x = x + 1;
                }
                if (76 == moves.charAt(i)) {
                    x = x - 1;
                }
                if (85 == moves.charAt(i)) {
                    y = y + 1;
                }

                if (68 == moves.charAt(i)) {
                    y = y - 1;
                }
            }
            return x == 0 && y == 0;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}
